package com.javaee.ch13.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.javaee.ch13.entity.Book;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.javaee.ch13.web.vo.BookCatVo1;
import com.javaee.ch13.web.vo.BookCategoryVo;
import com.javaee.ch13.web.vo.BookCategoryVo_1;
import com.javaee.ch13.web.vo.BookWithCopiesVo1;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 图书信息表 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2025-04-26
 */
@Mapper
public interface BookMapper extends BaseMapper<Book> {

    Page<Book> selectByPrice(@Param("page") Page<Book> page, @Param("price") Double price);

    BookWithCopiesVo1 selectBookWithCopiesByBookId(@Param("bookId") Long bookId);


    @Select("SELECT b.*, c.category_id as categoryId, c.category_name as categoryName from book b LEFT JOIN book_category c  on b.category_id = c.category_id WHERE book_id =#{bookId}")
    BookCategoryVo_1 selectBooKCategory( Long bookId);


    BookCatVo1 selectBookCatByBookId(@Param("bookId") Long bookId);



}
